{% extends "base_generic.html" %}

{% block title %}图书列表 - 本地图书馆{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header text-white" style="background-color: #FFDEAD;">
        <h1 class="h3 mb-0">
            <i class="fas fa-book me-2"></i>图书列表
        </h1>
    </div>
    <div class="card-body">
        <div class="row">
            {% for book in object_list %}
            <div class="col-md-6 mb-4">
                <div class="card h-100">
                    <div class="card-body">
                        <h5 class="card-title">
                            <a href="{{ book.get_absolute_url }}" class="text-decoration-none">
                                {{ book.title }}
                            </a>
                        </h5>
                        <h6 class="card-subtitle mb-2 text-muted">
                            <i class="fas fa-user me-1"></i>
                            <a href="{{ book.author.get_absolute_url }}" class="text-muted text-decoration-none">
                                {{ book.author }}
                            </a>
                        </h6>
                        <p class="card-text">{{ book.summary|truncatewords:30 }}</p>
                        <div class="mt-3">
                            <span class="badge bg-primary me-2">
                                <i class="fas fa-language me-1"></i>{{ book.language }}
                            </span>
                            {% for genre in book.genre.all %}
                            <span class="badge bg-secondary me-1">{{ genre }}</span>
                            {% endfor %}
                        </div>
                    </div>
                    <div class="card-footer bg-transparent">
                        <a href="{{ book.get_absolute_url }}" class="btn btn-outline-primary btn-sm">
                            <i class="fas fa-info-circle me-1"></i>查看详情
                        </a>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>

        {% if is_paginated %}
        <nav aria-label="分页" class="mt-4">
            <ul class="pagination justify-content-center">
                {% if page_obj.has_previous %}
                <li class="page-item">
                    <a class="page-link" href="?page={{ page_obj.previous_page_number }}">
                        <i class="fas fa-chevron-left"></i>
                    </a>
                </li>
                {% endif %}

                {% for i in paginator.page_range %}
                <li class="page-item {% if page_obj.number == i %}active{% endif %}">
                    <a class="page-link" href="?page={{ i }}">{{ i }}</a>
                </li>
                {% endfor %}

                {% if page_obj.has_next %}
                <li class="page-item">
                    <a class="page-link" href="?page={{ page_obj.next_page_number }}">
                        <i class="fas fa-chevron-right"></i>
                    </a>
                </li>
                {% endif %}
            </ul>
        </nav>
        {% endif %}
    </div>
</div>
{% endblock %} 